# -*- coding:utf-8 -*-
"""
Author：Administrator
Date:2023年03月21日
"""
import openpyxl

myBook=openpyxl.load_workbook('收入表.xlsx',data_only=True)
mySheet=myBook.active
myNewBook=openpyxl.Workbook()
myNewSheet=myNewBook.active
myNewSheet.title='收入表'
myNewSheet.append(['月份','公司名称','合计金额'])
myRows=list(mySheet.values)[1:]
myDict={}
for myRow in myRows:
	if myRow[1] in myDict.keys():
		myDict[myRow[1]]+=myRow[2]
	else:
		myDict[myRow[1]]=myRow[2]
for myName,myAmount in myDict.items():
	myNewSheet.append(['12月份',myName,myAmount])
myNewBook.save('结果表-收入表.xlsx')

